﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace T.FAS.Runtime.Metadata.Entity.DataModel
{
    public class TTransition : ICloneable
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public string ID { get; set; }

        /// <summary>
        /// 所属状态机ID
        /// </summary>
        [JsonIgnore]
        public string StateMachineID { get; set; }

        /// <summary>
        /// 开始状态ID
        /// </summary>
        public string FromStateID { get; set; }

        /// <summary>
        /// 结束状态ID
        /// </summary>
        public string ToStateID { get; set; }

        /// <summary>
        /// 事件ID
        /// </summary>
        public string EventID { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        /// 开始状态实例
        /// </summary>
        public TState From { get; set; }

        /// <summary>
        /// 结束状态实例
        /// </summary>
        public TState To { get; set; }

        /// <summary>
        /// 事件实例
        /// </summary>
        public TEvent Event { get; set; }

        /// <summary>
        /// 动作集合
        /// </summary>
        public List<TAction> Actions { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext1 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext2 { get; set; }

        /// <summary>
        /// 备用字段
        /// </summary>
        [JsonIgnore]
        public string Ext3 { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [JsonIgnore]
        public string Creator { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>        
        [JsonIgnore]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 最后修改人
        /// </summary>
        [JsonIgnore]
        public string LastModifier { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>   
        [JsonIgnore]
        public DateTime LastModifyTime { get; set; }

        public object Clone()
        {
            var newObject = this.MemberwiseClone() as TTransition;
            if (Actions != null)
            {
                newObject.Actions = new List<TAction>();
                this.Actions.ForEach(i => newObject.Actions.Add(i.Clone() as TAction));
            }
            return newObject;
        }
    }
}
